In today's computing environment, separated caches are commonly used in conjunction with storage devices such as hard disk drives. This is because use of a separated cache has many benefits. For instance, one benefit is increased performance of a computer system or storage device that the cache is used in conjunction with. Another benefit is decreased power consumption (which corresponds to increased battery life in a portable computer). Power consumption is decreased, because it takes less power to operate and access data from a cache than to operate and access the spinning media of a storage device, such as a hard disk drive, for every data access operation. However, the advantages that are realized through the use of a separated cache also come with some problems.
A major problem with using a separated cache is cache consistency. That is, ensuring that the data in the cache is kept consistent with the data on the storage device. When dealing cache consistency issues, at least two things are at stake. The first thing at stake is the cache data, which could be lost or corrupted. If the cache data is lost or corrupted, then the computing data that has been stored or revised for a time period, such as the last few minutes, may be lost. This would pose some annoyances, but would likely involve only a few percent of the total data of the storage device. The second thing at stake is the remaining data on the storage device. If this data is corrupted by improperly maintaining consistency with the cache, or by improperly synchronizing with the cache, the entire contents of the storage device may be lost.
The problem of cache consistency between a separated cache and a storage device is generally dealt with in one of two ways. The first way involves saving all data changes in the cache and then flushing cache data from the cache to the storage device through a process of ordered writes. In the ordered writes method, the cache data that is written to the cache is written back to the storage device in the exact order that it was written to the cache. The second way involves saving only the most recent changes to data within the cache and then flushing the cache data from the cache to the storage device by writing the cache data to each location that it is associated with (ordered writes need not be used).
One problem with the first-in-first-out ordered writes method is that it is far less efficient than possible. For example, the ordered writes method requires storing much more data in the separated cache than just the most recently changed data. This results in having a larger cache than may be needed or else inefficiently using the available space in the cache. Additionally, while the ordered writes method of writing cache data back to a storage device is a reliable way of ensuring consistency, it is a very slow way to flush cache data from a cache. For example, the ordered writes method typically causes seeks at random on a hard disk drive throughout the ordered write back process, even though many times the same location is sought out and written to several separate times. The cumulated time of these seeks is a main contributor to the slow speed of cache data flushing when using the ordered writes method.
Some of the problems of the ordered write method are resolved by using a method of caching which saves only the most recent version of data in the separated cache. As compared to the ordered writes method, this allows for either a smaller cache size or else more efficient use of the of the storage space available in the cache. Similarly, the speed of writing the cache data to the storage device during a cache flushing operation is increased as seeks for a particular location of the storage device are typically performed only one time. However, this method still suffers several problems. For example, as in the ordered writes method, random seeks are typically conducted on a hard drive as the cache data is written to various location on a hard disk drive storage device. This slows down the cache data flushing process. Additionally, if an interruption, such as a power failure, occurs during the synchronizing process, all data on the storage device may be corrupted due to a lack of consistency of the data, which is in various stages of update throughout the storage device.